﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;

namespace MINERP.DAL.Statistics
{
    public class FujiProductStaticDAL
    {
        /// <summary>
        /// 得到巨星与富士对帐的内部产品报表
        /// </summary>
        /// <param name="startDT"></param>
        /// <param name="endDT"></param>
        /// <returns></returns>
        public static DataTable GetProductInnerStatic(DateTime startDT, DateTime endDT)
        {
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("GetFujiInerCoun");
            db.AddInParameter(dbCommand, "@startTime", DbType.DateTime, startDT);
            db.AddInParameter(dbCommand, "@endTime", DbType.DateTime, endDT);

            DataSet dsPhoto = null;
            dsPhoto = db.ExecuteDataSet(dbCommand);


            DbCommand dbCommandComplete = db.GetStoredProcCommand("GetFujiInerCoun_Complete");
            db.AddInParameter(dbCommandComplete, "@startTime", DbType.DateTime, startDT);
            db.AddInParameter(dbCommandComplete, "@endTime", DbType.DateTime, endDT);

            DataSet dsPhotoComplete = null;
            dsPhotoComplete = db.ExecuteDataSet(dbCommandComplete);
            DataRow[] rows = dsPhotoComplete.Tables[0].Select();
            foreach (DataRow row in rows)
            {
                DataRow newrow = dsPhoto.Tables[0].NewRow();
                newrow.ItemArray = row.ItemArray;
                dsPhoto.Tables[0].Rows.Add(newrow);
            }

            return dsPhoto.Tables[0];
        }
    }
}
